package com.nbjtjc.safe.api.emg.handle;

import com.nbjtjc.safe.api.AbstractController;
import com.nbjtjc.safe.bean.Page;
import com.nbjtjc.safe.bean.Result;
import com.nbjtjc.safe.model.emg.handle.EmgHandlePublic;
import com.nbjtjc.safe.service.emg.handle.EmgHandlePublicService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@CrossOrigin("*")
@RequestMapping("/emgHandlePublic")
public class EmgHandlePublicController {

    @Autowired
    private EmgHandlePublicService emgHandlePublicService;

    @RequestMapping(value = "/add",method = {RequestMethod.POST})
    public Result add(@RequestBody EmgHandlePublic emgHandlePublic){
        Result result=new Result();
        try {
            result=emgHandlePublicService.add(emgHandlePublic);
        } catch (Exception e) {
            e.printStackTrace();
            result.setFalse(e.getMessage());
        }
        return result;
    }

    @RequestMapping(value = "/update",method = {RequestMethod.POST})
    public Result update(@RequestBody EmgHandlePublic emgHandlePublic){
        Result result=new Result();
        try {
            result=emgHandlePublicService.update(emgHandlePublic);
        } catch (Exception e) {
            e.printStackTrace();
            result.setFalse(e.getMessage());
        }
        return result;
    }

    @RequestMapping(value = "/delete",method = {RequestMethod.POST})
    public Result delete(@RequestBody int id) {
        Result result=new Result();
        try {
            result=emgHandlePublicService.delete(id);
        } catch (Exception e) {
            e.printStackTrace();
            result.setFalse(e.getMessage());
        }
        return result;
    }

    @RequestMapping(value = "/find",method = {RequestMethod.POST})
    public Result find(@RequestBody EmgHandlePublic emgHandlePublic) {
        Result result=new Result();
        try {
            result=emgHandlePublicService.find(emgHandlePublic);
        } catch (Exception e) {
            e.printStackTrace();
            result.setFalse(e.getMessage());
        }
        return result;
    }
}
